package android.slc.user.ui.user.delegate

import android.slc.adapter.SelectBox
import android.slc.appbase.ui.utils.ItemDecorationUtils
import android.slc.appbase.ui.vd.BaseListPageVd
import android.slc.extras.user.entity.UserInfo
import android.slc.user.ui.user.adapter.UserInfoMultipleAdapter
import android.slc.user.ui.user.vmbox.UserListMultipleVmBox
import android.slc.user.R
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.google.android.material.checkbox.MaterialCheckBox

/**
 *
 * @Description:
 * @Author: sunlunchang
 * @CreateDate: 2021/12/06 下午 2:55
 *
 */
class UserListMultipleDelegate :
    BaseListPageVd<SelectBox<UserInfo>, UserListMultipleVmBox>() {
    override fun initSwipeRecycler() {
        super.initSwipeRecycler()
        ItemDecorationUtils.addItemDecorationByRecyclerView(swipeRecycler.recyclerView)
    }

    override fun getAdapter(list: MutableList<SelectBox<UserInfo>>): BaseQuickAdapter<SelectBox<UserInfo>, BaseViewHolder> {
        return UserInfoMultipleAdapter(list)
    }

    override fun onAdapterItemClick(
        adapter: BaseQuickAdapter<SelectBox<UserInfo>, BaseViewHolder>,
        view: View,
        position: Int
    ) {
        //super.onAdapterItemClick(adapter, view, position)
        val selectBox: SelectBox<UserInfo> = adapter.getItem(position)
        vmBox.select(position, selectBox)
        view.findViewById<MaterialCheckBox>(R.id.checkbox).isChecked = selectBox.isChecked
    }

}